// Copyright 2011 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package dfa.axis.v1_16;

import com.google.api.ads.dfa.lib.client.DfaSession;
import com.google.api.ads.dfa.lib.factory.DfaServices;
import com.google.api.ads.dfa.axis.v1_16.SpotlightActivityGroup;
import com.google.api.ads.dfa.axis.v1_16.SpotlightActivityGroupSaveResult;
import com.google.api.ads.dfa.axis.v1_16.SpotlightRemote;

/**
 * This example creates a new activity group for a given spotlight
 * configuration. To get a spotlight tag configuration ID, run
 * GetAdvertisers.java. To get activity types, run GetActivityTypes.java.
 *
 * Credentials and properties in {@code fromFile()} are pulled from the
 * "ads.properties" file. See README for more info.
 *
 * Tags: spotlight.saveSpotlightActivityGroup
 *
 * @author Joseph DiLallo
 */
public class CreateSpotlightActivityGroup {

  public static void main(String[] args) throws Exception {
    long spotlightConfigurationId = Long.parseLong("INSERT_SPOTLIGHT_CONFIGURATION_ID_HERE");
    int activityType = Integer.parseInt("INSERT_ACTIVITY_TYPE_HERE");
    String groupName = "INSERT_GROUP_NAME_HERE";

    // Initialize your session.
    DfaSession session = new DfaSession.Builder().fromFile().build();

    // Request the service.
    SpotlightRemote service = new DfaServices().get(session, SpotlightRemote.class);

    // Set spotlight activity group structure.
    SpotlightActivityGroup spotlightActivityGroup = new SpotlightActivityGroup();
    spotlightActivityGroup.setId(0);
    spotlightActivityGroup.setName(groupName);
    spotlightActivityGroup.setSpotlightConfigurationId(spotlightConfigurationId);
    spotlightActivityGroup.setGroupType(activityType);

    // Create the activity group.
    SpotlightActivityGroupSaveResult activityGroupSaveResult =
        service.saveSpotlightActivityGroup(spotlightActivityGroup);

    // Display activity group ID.
    if (activityGroupSaveResult != null) {
      System.out.print("Activity group with ID \"" + activityGroupSaveResult.getId()
          + "\" was created.");
    }
  }
}
